# Maintainer: Hoang Nguyen <folliekazetani@protonmail.com>
pkgname=linuxkit
pkgver=1.0.1
pkgrel=0
pkgdesc="Toolkit for building immutable operating systems for containers"
url="https://github.com/linuxkit/linuxkit"
# 32-bit platforms: github.com/rn/iso9660wrap: integer overflow
# riscv64: fails to build
arch="all !x86 !armhf !armv7 !riscv64"
license="Apache-2.0"
makedepends="go"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/linuxkit/linuxkit/archive/refs/tags/v$pkgver.tar.gz"
builddir="$srcdir/$pkgname-$pkgver/src/cmd/linuxkit"

export CGO_ENABLED=0
export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	local _goldflags="
	-X github.com/linuxkit/linuxkit/src/cmd/linuxkit/version.GitCommit=AlpineLinux
	-X github.com/linuxkit/linuxkit/src/cmd/linuxkit/version.Version=v$pkgver
	"
	go build -v -ldflags "$_goldflags"
}

check() {
	go test ./...
}

package() {
	install -Dm755 $pkgname -t "$pkgdir"/usr/bin/

	mkdir -p "$pkgdir"/usr/share/doc/linuxkit/examples
	cp -r ../../../examples/*.yml "$pkgdir"/usr/share/doc/linuxkit/examples/
}

sha512sums="
4dbde5114a2e9f6adca69170430dbc916ef1d2d3c656b68a96a4eeff4f2dcbe6fd20640c9f28d98f4d7c7f4747a73d7c19fb36624c5d9f2e11565c6dc7ca981d  linuxkit-1.0.1.tar.gz
"
